import { App } from '@vue/composition-api'
import SvgIcon from './src/be-icon.vue'
import {ISvgIconComp} from '../../../types/be-icon'
const icon = SvgIcon as ISvgIconComp
/**
 * 组件装载方法
 * @param app
 */
icon.install = (app:App): void => {
    app.component(icon.name || '',icon)
}
const BeIcon:ISvgIconComp = icon
/**
 * 远程调用iconfont方法
 * @param url - 路径地址
 */
const customCache = new Set();
BeIcon.createFromIconfontCN = (url:string):void => {
    if (
        typeof document !== 'undefined' &&
        typeof window !== 'undefined' &&
        typeof document.createElement === 'function' &&
        typeof url === 'string' &&
        url.length &&
        !customCache.has(url)
    ) {
        const script = document.createElement('script');
        script.setAttribute('src', url);
        script.setAttribute('data-namespace', url);
        customCache.add(url);
        document.body.appendChild(script);
    }
}
export default BeIcon
export const createFromIconfontCN = BeIcon.createFromIconfontCN;
